package com.ptswitch.material.model.material;

import javax.validation.constraints.Size;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hxzon.project.BaseEntity;

public class BomMaterial extends BaseEntity implements Comparable<BomMaterial> {

    private static final long serialVersionUID = -2394146567804248902L;

    private Material material;

    private Bom bom;

    @Size(max = DefineSize32)
    private String code;

    @Size(max = DefineSize2048)
    private String designator;// 元件编号

    @Size(max = DefineSize2048)
    private String comment;// 规格描述

    @Size(max = DefineSize2048)
    private String footprint;// PCB封装

    @Size(max = DefineSize2048)
    private String value;

    @Size(max = DefineSize2048)
    private String voltage;// 电压

    @Size(max = DefineSize2048)
    private String quantity;// 数量

    @Size(max = DefineSize2048)
    private String stuffOpt;// 材料选择

    public Material getMaterial() {
        return material;
    }

    public void setMaterial(Material material) {
        this.material = material;
    }

    public Bom getBom() {
        return bom;
    }

    public void setBom(Bom bom) {
        this.bom = bom;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getDesignator() {
        return designator;
    }

    public void setDesignator(String designator) {
        this.designator = designator;
    }

    public String getFootprint() {
        return footprint;
    }

    public void setFootprint(String footprint) {
        this.footprint = footprint;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getVoltage() {
        return voltage;
    }

    public void setVoltage(String voltage) {
        this.voltage = voltage;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getStuffOpt() {
        return stuffOpt;
    }

    public void setStuffOpt(String stuffOpt) {
        this.stuffOpt = stuffOpt;
    }

    @Override
    public String toString() {
        return this.code + "::(" + this.material + ")::(" + this.bom + ")";
    }

    public String print() {
        StringBuilder sb = new StringBuilder();
        sb.append("(materiel:").append(material).append("),(bom:").append(bom).append("),code:").append(code).append(",designator:").append(designator).append(",footprint:").append(footprint)
                .append(",value:").append(value).append(",voltage:").append(voltage).append(",quantity:").append(quantity).append(",stuffOpt:").append(stuffOpt);
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof BomMaterial)) {
            return false;
        }
        BomMaterial other = (BomMaterial) o;
        return new EqualsBuilder().append(this.code, other.getCode()).append(this.stuffOpt, other.getStuffOpt()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(this.code).append(this.stuffOpt).toHashCode();
    }

    @Override
    public int compareTo(BomMaterial o) {
        return this.code.compareTo(o.getCode());
    }

}
